package com.example.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * Ajax响应结果
 */
@ApiModel("Ajax响应结果")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult {
    @ApiModelProperty("响应状态码")
    private Integer status;

    @ApiModelProperty("响应消息")
    private String msg;

    @ApiModelProperty("响应数据")
    private Object data;

    public static AjaxResult success(int status, String msg, Object data){
        return new AjaxResult(status, msg, data);
    }

    public static AjaxResult success(String msg){
        return new AjaxResult(200, msg, null);
    }

    public static AjaxResult success(Object data){
        return new AjaxResult(200, "success", data);
    }

    public static AjaxResult success(String msg, Object data){
        return new AjaxResult(200, msg, data);
    }

    public static AjaxResult success(){
        return new AjaxResult(200, "success", null);
    }

    public static AjaxResult fail(int status, String msg){
        return new AjaxResult(status, msg, null);
    }

    public static AjaxResult fail(String msg){
        return new AjaxResult(500, msg, null);
    }
}
